package com.xinqing.test.LetCode;

/**
 * @Author:CHQ
 * @Date:2021/7/20 15:16
 * @Description
 */
public class LongestCommonPrefix {
    public static void main(String[] args){
        String[] words={"flower","flow","flight"};

        String x=words[0];

        for(String s:words){
            while(!s.startsWith(x)){
              x=x.substring(0,x.length()-1);
            }
        }

        System.out.println(x);
    }
}
